/**
 * 
 */
package base.game;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;

public abstract class BaseShip {
	protected int points[][];
	protected RectF area;
	
	public abstract void onDraw(Canvas canvas, Paint paint);
	
	public void onDrawToEnemy(Canvas canvas) {
		Paint p =new Paint();
		p.setColor(Color.RED);
		p.setAlpha(200);
		if(points!=null){
			for (int i = 0; i < points.length; i++) {
				if (points[i][2] == 1) {
					float left = Map.mapStartX + points[i][0] * Map.rowWidth;
					float right = left + Map.rowWidth;
					float top = Map.mapStartY + points[i][1] * Map.rowHeight;
					float bottom = top + Map.rowHeight;
					canvas.drawRect(left, top, right, bottom, p);
				}
			}
		}
	}
	
	public abstract void onUpdate(long difftime);
	
	public abstract boolean move(Map map, float touchX, float touchY);
	
	public abstract boolean canBePlaced(Map map, float touchX, float touchY);

	public boolean collided(int x, int y) {
		if (points != null) {
			for (int i = 0; i < points.length; i++) {
				if (x == points[i][0] && y == points[i][1]) {
					return true;
				}
			}
		}
		return false;
	}

	public void takeDamage(int touchX, int touchY) {
		points[touchX][touchY] = 1;
	}

}
